home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL2.LZH / GETDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1984-07-13  |  2KB  |  104 lines

  1. PROGRAM DIR;
  2. {
  3.            JUNE 28, 1984
  4.  
  5.            Author:       Todd Little
  6.                          1318 Bullock
  7.                          Houston, TX  77055
  8.                          713-984-2055 h
  9.                              578-3210 w
  10.  
  11. }
  12.  
  13. VAR
  14.    es,bx :INTEGER;
  15.    al :BYTE;
  16.    file_search : STRING[20];
  17.  
  18. PROCEDURE getdta;
  19.  
  20. {
  21.    Get the current DTA (data transfer address)
  22.    Use the DOS call 2f to put the DTA into ES:BX
  23.    Then put these into the variables of the same name
  24.  
  25. }
  26. BEGIN
  27.   INLINE
  28.     ( $b4/$2f/          {mov ah,2f}
  29.       $cd/$21/          {int,21}
  30.       $89/$1e/bx/       {mov (bx),bx  }
  31.       $8c/$c3/          {mov bx,es }
  32.       $89/$1e/es        {mov (es),bx  }
  33.         )
  34.    END;
  35.  
  36.  
  37.  
  38. PROCEDURE getdir(VAR file_search);
  39.  
  40. {
  41.     Get the directory by using the find first operation, dos call 4e
  42.     get subsequent entries using dos call 4f
  43.  
  44.     file_search  should contain the matching parameters, i.e. *.*
  45. }
  46. VAR
  47.    i,j : INTEGER;
  48.    file_name : STRING[20];
  49.  
  50.  
  51. BEGIN
  52.  
  53.  
  54.    BEGIN;
  55.       INLINE  (
  56.          $8b/$56/$04/    {mov dx,[bp+04]    point to file_search}
  57.          $81/$c2/$01/$00/{add dx,0001       move past the string length}
  58.          $b9/$00/$00/    {mov cx,0010       search for files (inc dir)}
  59.          $b4/$4e/        {mov ah,4e         dos call 4e}
  60.          $cd/$21/        {int 21h           }
  61.          $a2/al          {mov (al),al       save the error code}
  62.            )
  63.       END;
  64.  
  65.    j := 0;
  66.    WRITELN;
  67.  
  68.    WHILE (al <> 02) AND (al <> 18) DO
  69.    BEGIN
  70.  
  71.       IF j MOD 5 = 0 THEN
  72.          WRITELN;
  73.  
  74.       i := 30;
  75.       file_name := '';
  76.  
  77.       WHILE MEM[es:bx+i] <> 0 DO
  78.       BEGIN
  79.         file_name := CONCAT(file_name,CHR(MEM[es:bx+i]) );
  80.         i := i +1;
  81.       END;
  82.  
  83.       WRITE(file_name:15);
  84.       j := j +1;
  85.  
  86.       BEGIN
  87.       INLINE  (
  88.          $b4/$4f/        {mov ah,4f         find next}
  89.          $cd/$21/        {int 21h           with dos call 4f}
  90.          $a2/al          {mov (al),al       save return code}
  91.            )
  92.       END;
  93.  
  94.   END;
  95.  
  96. END;
  97.  
  98. BEGIN
  99.  
  100.    getdta;
  101.    file_search := CONCAT( '*.*',CHR(0) );
  102.    getdir(file_search);
  103.    END.
  104.